﻿using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using HPT;
using System.Collections.Generic;

namespace News.WebParts.SangTacWebPart
{
    public partial class SangTacWebPartUserControl : UserControl, IViewNews
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            presenterNews = new PresenterNews(this);
            if (!Page.IsPostBack)
            {
                presenterNews.GetAllNewsByCategory();
            }
        }


        PresenterNews presenterNews;

        public List<NewsModal> AllNews
        {
            get
            {
                if (ViewState["AllNews"] == null) ViewState["AllNews"] = new List<NewsModal>();
                return (List<NewsModal>)ViewState["AllNews"];
            }
            set
            {
                ViewState["AllNews"] = value;
                rptSangTac.DataSource = value;
                rptSangTac.DataBind();
            }
        }

        public string NewsCategory
        {
            get
            {
                return "Sáng tác";
            }
            set
            {
                ViewState["Category"] = value;
            }
        }


        public int RowLimit
        {
            get
            {
                if ((int)ViewState["RowLimit"] == 0) ViewState["RowLimit"] = 1;
                return (int)ViewState["RowLimit"];
            }
            set
            {
                ViewState["RowLimit"] = value;
            }
        }
    }
}
